<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Hoodoo::Generator</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
    <div class="banner">
        <h1>
            <span class="type">Class</span>
            Hoodoo::Generator
                <span class="parent">&lt;
                    Object
                </span>
        </h1>
        <ul class="files">
            <li><a href="../../files/lib/hoodoo/generator_rb.html">lib/hoodoo/generator.rb</a></li>
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
    <div class="description">
      
<p>Implement the <code>hoodoo</code> command line interface.</p>

    </div>








    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
        <dt>R</dt>
        <dd>
          <ul>
              <li>
                <a href="#method-i-run-21">run!</a>
              </li>
          </ul>
        </dd>
    </dl>

    <!-- Includes -->
    <div class="sectiontitle">Included Modules</div>
    <ul>
        <li>
            Singleton
        </li>
    </ul>






      <!-- Section constants -->
      <div class="sectiontitle">Constants</div>
      <table border='0' cellpadding='5'>
          <tr valign='top' id='KERNEL_EXIT_SUCCESS'>
            <td class="attr-name">KERNEL_EXIT_SUCCESS</td>
            <td>=</td>
            <td class="attr-value"><pre>true</pre></td>
          </tr>
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"><p>Kernel::exit takes a boolean but defines no constants to describe what it
means; very bad form. This constant equates to the &#39;success&#39;
boolean value.</p></td>
            </tr>
          <tr valign='top' id='KERNEL_EXIT_FAILURE'>
            <td class="attr-name">KERNEL_EXIT_FAILURE</td>
            <td>=</td>
            <td class="attr-value"><pre>false</pre></td>
          </tr>
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"><p>Kernel::exit takes a boolean but defines no constants to describe what it
means; very bad form. This constant equates to the &#39;failed&#39; boolean
value.</p></td>
            </tr>
          <tr valign='top' id='NAME_REGEX'>
            <td class="attr-name">NAME_REGEX</td>
            <td>=</td>
            <td class="attr-value"><pre>/^[a-zA-Z01-9_-]{2,30}$/</pre></td>
          </tr>
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"><p>Regular expression describing allowed names of services (A-Z, a-z, 0-9,
underscore or hyphen; between 2 and 30 characters).</p></td>
            </tr>
      </table>



    <!-- Methods -->
      <div class="sectiontitle">Instance Public methods</div>
        <div class="method">
          <div class="title method-title" id="method-i-run-21">
              <b>run!</b>( args )
            <a href="../../classes/Hoodoo/Generator.html#method-i-run-21" name="method-i-run-21" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Run the <code>hoodoo</code> command implementation.</p>
<dl class="rdoc-list note-list"><dt>args
<dd>
<p>Array of command line arguments, excluding the <code>hoodoo</code> command
itself (so, just any extra arguments passed in).</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-run-21_source')" id="l_method-i-run-21_source">show</a>
              </p>
              <div id="method-i-run-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/generator.rb, line 43</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">run!</span>( <span class="ruby-identifier">args</span> )
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">show_usage</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">args_empty?</span>(<span class="ruby-identifier">args</span>)

  <span class="ruby-identifier">name</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">show_usage</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;-h&#39;</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;--help&#39;</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">usage_and_warning</span>( <span class="ruby-node">&quot;SERVICE_NAME must match #{ NAME_REGEX.inspect }&quot;</span> ) <span class="ruby-keyword">if</span> <span class="ruby-identifier">naughty_name?</span>( <span class="ruby-identifier">name</span> )
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">usage_and_warning</span>( <span class="ruby-node">&quot;&#39;#{ name }&#39; already exists&quot;</span> ) <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>( <span class="ruby-node">&quot;./#{ name }&quot;</span> )

  <span class="ruby-identifier">git</span> = <span class="ruby-identifier">args</span>[ <span class="ruby-number">2</span> ] <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>[ <span class="ruby-number">1</span> ] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;--from&#39;</span>
  <span class="ruby-identifier">git</span> <span class="ruby-operator">||=</span> <span class="ruby-string">&#39;git@github.com:LoyaltyNZ/service_shell.git&#39;</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">create_service</span>( <span class="ruby-identifier">name</span>, <span class="ruby-identifier">git</span> )
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
</div>

    </div>
  </body>
</html>
